import JsEncrypt from 'jsencrypt'

export const publicKey = `-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3HNepgRSr1HzLlmzc7jP
wUlr74dsRsvEgRiHjURMdQnfT4cXLxTEcebVEtY2qFJHMAmmTObag9wFc0ZKmlhQ
JUncQlnxIN/a0uxzWbF5BJeBxVd3jF2+79qHwpLNqrAt793RiX5HyqCgHDquEf+8
HTc0iku81t/gdlRmp5o4nsUyMLijnkHRqepd/GAP5CTqGi1dduDJ8p/IbGBDnWlF
mwe6xup91JOmX4g9d1N/53rZ1LFkcGcTF3To1RcPW1M96fqoP7qO3Dwm7g5hnLdv
nL+YLpNM8HQ/4W0nqR4M5lnhw+xnLTuwermgeGTVSQWU9XUKHRVb82Sqj+d8Z0OA
qQIDAQAB
-----END PUBLIC KEY-----
`
export const privateKey = `-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDcc16mBFKvUfMu
WbNzuM/BSWvvh2xGy8SBGIeNREx1Cd9PhxcvFMRx5tUS1jaoUkcwCaZM5tqD3AVz
RkqaWFAlSdxCWfEg39rS7HNZsXkEl4HFV3eMXb7v2ofCks2qsC3v3dGJfkfKoKAc
Oq4R/7wdNzSKS7zW3+B2VGanmjiexTIwuKOeQdGp6l38YA/kJOoaLV124Mnyn8hs
YEOdaUWbB7rG6n3Uk6ZfiD13U3/netnUsWRwZxMXdOjVFw9bUz3p+qg/uo7cPCbu
DmGct2+cv5guk0zwdD/hbSepHgzmWeHD7GctO7B6uaB4ZNVJBZT1dQodFVvzZKqP
53xnQ4CpAgMBAAECggEAUgx+hbvGKoqNwAqSx9dZO89f5N66Zf8hPAstKF7rNgRe
oPLeph9MnjgTxdcEsNEuvapZwvWJDtqtDKJ00c1cxwQefnOLU3j9sNNge1maeSMK
obBURmH91re3H6wT8BtyfXxJqKrffYMbFGaiswBDu3v4iiB2QGNC38e6DVdRC4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ATE KEY-----
`
// 加密
export function encrypt (txt) {
  const encryptor = new JsEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt (txt) {
  const encryptor = new JsEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}
